<?php

/**
 * Application Models
 *
 * @package Application_Model
 * @subpackage Model
 * @author <YOUR NAME HERE>
 * @copyright ZF model generator
 * @license http://framework.zend.com/license/new-bsd     New BSD License
 */

/**
 * Abstract class for models
 */
require_once 'ModelAbstract.php';

/**
 * 
 *
 * @package Application_Model
 * @subpackage Model
 * @author <YOUR NAME HERE>
 */
class Application_Model_Actualites extends Application_Model_ModelAbstract
{

    /**
     * Database var type int(4)
     *
     * @var int
     */
    protected $_IdActualite;

    /**
     * Database var type varchar(100)
     *
     * @var string
     */
    protected $_Titre;

    /**
     * Database var type longtext
     *
     * @var text
     */
    protected $_Description;

    /**
     * Database var type datetime
     *
     * @var string
     */
    protected $_DateHeure;

    /**
     * Database var type varchar(200)
     *
     * @var string
     */
    protected $_Image;

    /**
     * Database var type int(4)
     *
     * @var int
     */
    protected $_SessionIdSession;


    /**
     * Parent relation fk_actualites_session1
     *
     * @var Application_Model_Session
     */
    protected $_Session;


    /**
     * Sets up column and relationship lists
     */
    public function __construct()
    {
        parent::init();
        $this->setColumnsList(array(
            'id_actualite'=>'IdActualite',
            'titre'=>'Titre',
            'description'=>'Description',
            'date_heure'=>'DateHeure',
            'image'=>'Image',
            'session_id_session'=>'SessionIdSession',
        ));

        $this->setParentList(array(
            'FkActualitesSession1'=> array(
                    'property' => 'Session',
                    'table_name' => 'Session',
                ),
        ));

        $this->setDependentList(array(
        ));
    }

    /**
     * Sets column id_actualite
     *
     * @param int $data
     * @return Application_Model_Actualites
     */
    public function setIdActualite($data)
    {
        $this->_IdActualite = $data;
        return $this;
    }

    /**
     * Gets column id_actualite
     *
     * @return int
     */
    public function getIdActualite()
    {
        return $this->_IdActualite;
    }

    /**
     * Sets column titre
     *
     * @param string $data
     * @return Application_Model_Actualites
     */
    public function setTitre($data)
    {
        $this->_Titre = $data;
        return $this;
    }

    /**
     * Gets column titre
     *
     * @return string
     */
    public function getTitre()
    {
        return $this->_Titre;
    }

    /**
     * Sets column description
     *
     * @param text $data
     * @return Application_Model_Actualites
     */
    public function setDescription($data)
    {
        $this->_Description = $data;
        return $this;
    }

    /**
     * Gets column description
     *
     * @return text
     */
    public function getDescription()
    {
        return $this->_Description;
    }

    /**
     * Sets column date_heure. Stored in ISO 8601 format.
     *
     * @param string|Zend_Date $date
     * @return Application_Model_Actualites
     */
    public function setDateHeure($data)
    {
        if (! empty($data)) {
            if (! $data instanceof Zend_Date) {
                $data = new Zend_Date($data);
            }

            $data = $data->toString(Zend_Date::ISO_8601);
        }

        $this->_DateHeure = $data;
        return $this;
    }

    /**
     * Gets column date_heure
     *
     * @param boolean $returnZendDate
     * @return Zend_Date|null|string Zend_Date representation of this datetime if enabled, or ISO 8601 string if not
     */
    public function getDateHeure($returnZendDate = false)
    {
        if ($returnZendDate) {
            if ($this->_DateHeure === null) {
                return null;
            }

            return new Zend_Date($this->_DateHeure, Zend_Date::ISO_8601);
        }

        return $this->_DateHeure;
    }

    /**
     * Sets column image
     *
     * @param string $data
     * @return Application_Model_Actualites
     */
    public function setImage($data)
    {
        $this->_Image = $data;
        return $this;
    }

    /**
     * Gets column image
     *
     * @return string
     */
    public function getImage()
    {
        return $this->_Image;
    }

    /**
     * Sets column session_id_session
     *
     * @param int $data
     * @return Application_Model_Actualites
     */
    public function setSessionIdSession($data)
    {
        $this->_SessionIdSession = $data;
        return $this;
    }

    /**
     * Gets column session_id_session
     *
     * @return int
     */
    public function getSessionIdSession()
    {
        return $this->_SessionIdSession;
    }

    /**
     * Sets parent relation SessionIdSession
     *
     * @param Application_Model_Session $data
     * @return Application_Model_Actualites
     */
    public function setSession(Application_Model_Session $data)
    {
        $this->_Session = $data;

        $primary_key = $data->getPrimaryKey();
        if (is_array($primary_key)) {
            $primary_key = $primary_key['id_session'];
        }

        $this->setSessionIdSession($primary_key);

        return $this;
    }

    /**
     * Gets parent SessionIdSession
     *
     * @param boolean $load Load the object if it is not already
     * @return Application_Model_Session
     */
    public function getSession($load = true)
    {
        if ($this->_Session === null && $load) {
            $this->getMapper()->loadRelated('FkActualitesSession1', $this);
        }

        return $this->_Session;
    }

    /**
     * Returns the mapper class for this model
     *
     * @return Application_Model_Mapper_Actualites
     */
    public function getMapper()
    {
        if ($this->_mapper === null) {
            $this->setMapper(new Application_Model_Mapper_Actualites());
        }

        return $this->_mapper;
    }

    /**
     * Deletes current row by deleting the row that matches the primary key
     *
	 * @see Application_Model_Mapper_Actualites::delete
     * @return int|boolean Number of rows deleted or boolean if doing soft delete
     */
    public function deleteRowByPrimaryKey()
    {
        if ($this->getIdActualite() === null) {
            throw new Exception('Primary Key does not contain a value');
        }

        return $this->getMapper()
                    ->getDbTable()
                    ->delete('id_actualite = ' .
                             $this->getMapper()
                                  ->getDbTable()
                                  ->getAdapter()
                                  ->quote($this->getIdActualite()));
    }
}
